local midang = fk.CreateSkill{
  name = "plum__midang_response",
}

Fk:loadTranslationTable{
  [midang.name] = "密党",

  ["#plum__midang-response"] = "密党：可以通过令%src摸一张牌来抵消%arg",
}

midang:addEffect(fk.PreCardEffect, {
  mute = true,
  can_trigger = function (self, event, target, player, data)
    if data.to == player and player:getMark("@@plum__midang") == 1
    and (data.card.type == Card.TypeBasic or data.card:isCommonTrick())
    and not (data.unoffsetable or data:isUnoffsetable(player))
    and not (data.disresponsive or data:isDisresponsive(player)) then
      player.room:setPlayerMark(player, "@@plum__midang", 0)
      return true
    end
  end,
  on_cost = Util.TrueFunc,
  on_use = function (self, event, target, player, data)
    local room = player.room
    local boss = player:getMark("plum__midang_boss") ---@type integer
    if boss and room:askToSkillInvoke(player, { skill_name = "plum__midang", prompt = "#plum__midang-response:"..boss.."::"..data.card:toLogString() }) then
      room:getPlayerById(boss):drawCards(1, "plum__midang")
      data.isCancellOut = true
    else
      data.use.unoffsetableList = data.use.unoffsetableList or {}
      table.insert(data.use.unoffsetableList, player)
    end
  end,
})

return midang